//
//  UIBarButtonItem+Extension.m
//  云+物娱
//
//  Created by yiguo qi on 2017/11/29.
//  Copyright © 2017年 ICE. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

+ (UIBarButtonItem *)itemWithImage:(NSString *)image higlightedImage:(NSString *)hilight target:(id)target action:(SEL)action
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    UIImage *normal  = [UIImage imageNamed:image];
    [btn setImage:normal forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:hilight]forState:UIControlStateHighlighted];
    btn.bounds = CGRectMake(0, 0, normal.size.width, 30);
//    btn.backgroundColor = [UIColor greenColor];
//    btn.imageEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 0);
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

+ (UIBarButtonItem *)itemWithTitle:(NSString *)title target:(id)target action:(SEL)action{
   
    return [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:target action:action];
}
@end
